package com.lovo.csc.controller;


import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lovo.csc.dto.ExpenseDto;
import com.lovo.csc.dto.PrepayDto;
import com.lovo.csc.entity.Discount;
import com.lovo.csc.entity.Prepay;
import com.lovo.csc.entity.PrepayRecord;
import com.lovo.csc.service.IDiscountService;
import com.lovo.csc.service.IPrepayRecordService;
import com.lovo.csc.service.IPrepayService;
import com.lovo.remoteservice.IPayService;
import com.lovo.sscweb.dto.OrderDto;
import com.lovo.sscweb.dto.OrderItemTo;
import com.lovo.util.MQUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 客户预存款消费的记录 前端控制器
 * </p>
 *
 * @author lovo
 * @since 2022-07-07
 */
@RestController
@RequestMapping("/prepay-record")
@Api(tags = "预存款消费记录操作层 文林挥 001")
public class PrepayRecordController {
    @Autowired
    IPrepayRecordService service;
    @Autowired
    IPrepayService prepayService;
    @Autowired
    IDiscountService discountService;
    @Autowired
    RabbitTemplate rabbitTemplate;
    @Autowired
    RedisTemplate redisTemplate;
    @Autowired
    IPayService payService;


    @ApiOperation("查看存款消预费记录")
    @PostMapping("findRecords")
    public IPage findPrepayExpense(String userCode,int currentPage){
        IPage<PrepayRecord> page=new Page<>();
        page.setSize(5);
        page.setCurrent(currentPage);
        QueryWrapper<PrepayRecord> qw=new QueryWrapper<>();
        qw.eq("user_code",userCode);
        return service.page(page,qw);
    }
    @ApiOperation(value = "待审核的预存款消费")
    @GetMapping("getAudit")
    public Object getAudit(){
        boolean exist= redisTemplate.hasKey("order");
        if (exist){
            return redisTemplate.opsForHash().values("order");
        }
        return null;
    }
}
